import axios from 'axios';
import env from '../config/env';
import qs from 'qs';

let util = {

};
util.title = function(title) {
    title = title ? title + ' - Home' : 'iView project';
    window.document.title = title;
};

const ajaxUrl = env === 'development' ?
    '/api/' :
    env === 'production' ?
    '/api/' :
    'https://debug.url.com';

util.ajax = axios.create({
    baseURL: ajaxUrl,
    timeout: 30000,
    headers:{
        'Content-Type':'application/x-www-form-urlencoded'
    },
    transformRequest: [function (data) {
        return qs.stringify(data);
    }],
});

export default util;